package org.qiyu.live.im.provider.service.impl;

import jakarta.annotation.Resource;
import org.qiyu.live.common.interfaces.enums.ImCoreServerIPRedisKey;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import org.qiyu.live.im.provider.service.ImOnlineService;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: sfx
 * Date: 2023-10-27
 * Time: 20:30
 */
@Service
public class ImOnlineServiceImpl implements ImOnlineService {

    @Resource
    private StringRedisTemplate stringRedisTemplate;

    @Override
    public boolean isOnline(Long userId, Integer appId) {
        // imCoreServerIp:100001:100001
        return stringRedisTemplate.hasKey(ImCoreServerIPRedisKey.ImCoreServerIp + appId + ":" + userId);
    }
}
